package com.logos.musicframe.service.impl;

import com.logos.musicframe.entity.LikedCount;
import com.logos.musicframe.mapper.LikedCountMapper;
import com.logos.musicframe.service.LikedCountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 歌曲点赞计数表(LikedCount)表服务实现类
 *
 * @author rose
 * @since 2025-06-02 23:00:31
 */
@Service("likedCountService")
@Slf4j
public class LikedCountServiceImpl implements LikedCountService {
    @Autowired
    private LikedCountMapper likedCountMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public LikedCount queryById(Long id) {
        return this.likedCountMapper.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param likedCount 实例对象
     * @return 实例对象
     */
    @Override
    public LikedCount insert(LikedCount likedCount) {
        this.likedCountMapper.insert(likedCount);
        return likedCount;
    }

    /**
     * 修改数据
     *
     * @param likedCount 实例对象
     * @return 实例对象
     */
    @Override
    public LikedCount update(LikedCount likedCount) {
        this.likedCountMapper.update(likedCount);
        return this.queryById(likedCount.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.likedCountMapper.deleteById(id) > 0;
    }
}
